struct
{
- gchar *theme_class;
+ GtkWin32Theme *theme;
gint id;
} win32;
} sym_col;
_gtk_css_value_unref (color->sym_col.mix.color2);
break;
case COLOR_TYPE_WIN32:
- g_free (color->sym_col.win32.theme_class);
+ gtk_win32_theme_unref (color->sym_col.win32.theme);
break;
default:
break;
{
GdkRGBA res;
- if (!_gtk_win32_theme_color_resolve (color->sym_col.win32.theme_class,
- color->sym_col.win32.id,
- &res))
- return NULL;
+ gtk_win32_theme_get_color (color->sym_col.win32.theme,
+ color->sym_col.win32.id,
+ &res);
value = _gtk_css_rgba_value_new_from_rgba (&res);
}
_gtk_css_value_equal (value1->sym_col.mix.color2,
value2->sym_col.mix.color2);
case COLOR_TYPE_WIN32:
- return g_str_equal (value1->sym_col.win32.theme_class, value2->sym_col.win32.theme_class) &&
+ return gtk_win32_theme_equal (value1->sym_col.win32.theme, value2->sym_col.win32.theme) &&
value1->sym_col.win32.id == value2->sym_col.win32.id;
case COLOR_TYPE_CURRENT_COLOR:
return TRUE;
break;
case COLOR_TYPE_WIN32:
{
- g_string_append_printf (string, GTK_WIN32_THEME_SYMBOLIC_COLOR_NAME"(%s, %d)",
- value->sym_col.win32.theme_class, value->sym_col.win32.id);
+ g_string_append (string, GTK_WIN32_THEME_SYMBOLIC_COLOR_NAME"(");
+ gtk_win32_theme_print (value->sym_col.win32.theme, string);
+ g_string_append_printf (string, "%d)", value->sym_col.win32.id);
}
break;
case COLOR_TYPE_CURRENT_COLOR:
return value;
}
+static GtkCssValue *
+gtk_css_color_value_new_win32_for_theme (GtkWin32Theme *theme,
+ gint id)
+{
+ GtkCssValue *value;
+
+ gtk_internal_return_val_if_fail (theme != NULL, NULL);
+
+ value = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_COLOR);
+ value->type = COLOR_TYPE_WIN32;
+ value->sym_col.win32.theme = gtk_win32_theme_ref (theme);
+ value->sym_col.win32.id = id;
+
+ return value;
+}
+
GtkCssValue *
_gtk_css_color_value_new_win32 (const gchar *theme_class,
gint id)
{
+ GtkWin32Theme *theme;
GtkCssValue *value;
gtk_internal_return_val_if_fail (theme_class != NULL, NULL);
- value = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_COLOR);
- value->type = COLOR_TYPE_WIN32;
- value->sym_col.win32.theme_class = g_strdup (theme_class);
- value->sym_col.win32.id = id;
+ theme = gtk_win32_theme_lookup (theme_class);
+ value = gtk_css_color_value_new_win32_for_theme (theme, id);
+ gtk_win32_theme_unref (theme);
return value;
}
gtk_css_color_parse_win32 (GtkCssParser *parser)
{
GtkCssValue *color;
- char *class;
+ GtkWin32Theme *theme;
int id;
- class = _gtk_css_parser_try_name (parser, TRUE);
- if (class == NULL)
- {
- _gtk_css_parser_error (parser,
- "Expected name as first argument to '-gtk-win32-color'");
- return NULL;
- }
+ theme = gtk_win32_theme_parse (parser);
+ if (theme == NULL)
+ return NULL;
if (! _gtk_css_parser_try (parser, ",", TRUE))
{
- g_free (class);
+ gtk_win32_theme_unref (theme);
_gtk_css_parser_error (parser,
"Expected ','");
return NULL;
if (!_gtk_css_parser_try_int (parser, &id))
{
- g_free (class);
+ gtk_win32_theme_unref (theme);
_gtk_css_parser_error (parser, "Expected a valid integer value");
return NULL;
}
- color = _gtk_css_color_value_new_win32 (class, id);
- g_free (class);
+ color = gtk_css_color_value_new_win32_for_theme (theme, id);
+ gtk_win32_theme_unref (theme);
return color;
}
SIZE *psz);
static GetThemeSysFontFunc get_theme_sys_font = NULL;
-static GetThemeSysColorFunc get_theme_sys_color = NULL;
+static GetThemeSysColorFunc GetThemeSysColor = NULL;
static GetThemeSysSizeFunc get_theme_sys_metric = NULL;
static OpenThemeDataFunc OpenThemeData = NULL;
static CloseThemeDataFunc CloseThemeData = NULL;
draw_theme_background = (DrawThemeBackgroundFunc) GetProcAddress (uxtheme_dll, "DrawThemeBackground");
enable_theme_dialog_texture = (EnableThemeDialogTextureFunc) GetProcAddress (uxtheme_dll, "EnableThemeDialogTexture");
get_theme_sys_font = (GetThemeSysFontFunc) GetProcAddress (uxtheme_dll, "GetThemeSysFont");
- get_theme_sys_color = (GetThemeSysColorFunc) GetProcAddress (uxtheme_dll, "GetThemeSysColor");
+ GetThemeSysColor = (GetThemeSysColorFunc) GetProcAddress (uxtheme_dll, "GetThemeSysColor");
get_theme_sys_metric = (GetThemeSysSizeFunc) GetProcAddress (uxtheme_dll, "GetThemeSysSize");
is_theme_partially_transparent = (IsThemeBackgroundPartiallyTransparentFunc) GetProcAddress (uxtheme_dll, "IsThemeBackgroundPartiallyTransparent");
draw_theme_parent_background = (DrawThemeParentBackgroundFunc) GetProcAddress (uxtheme_dll, "DrawThemeParentBackground");
return g_ascii_strdown (classname, -1);
}
-static GtkWin32Theme *
+GtkWin32Theme *
gtk_win32_theme_lookup (const char *classname)
{
GtkWin32Theme *theme;
+ char *canonical_classname;
if (G_UNLIKELY (themes_by_class == NULL))
themes_by_class = g_hash_table_new (g_str_hash, g_str_equal);
- theme = g_hash_table_lookup (themes_by_class, classname);
+ canonical_classname = canonicalize_class_name (classname);
+ theme = g_hash_table_lookup (themes_by_class, canonical_classname);
if (theme != NULL)
- return gtk_win32_theme_ref (theme);
+ {
+ g_free (canonical_classname);
+ return gtk_win32_theme_ref (theme);
+ }
theme = g_slice_new0 (GtkWin32Theme);
theme->ref_count = 1;
- theme->class_name = g_strdup (classname);
+ theme->class_name = canonical_classname;
g_hash_table_insert (themes_by_class, theme->class_name, theme);
gtk_win32_theme_parse (GtkCssParser *parser)
{
GtkWin32Theme *theme;
- char *canonical_class_name, *class_name;
+ char *class_name;
class_name = _gtk_css_parser_try_name (parser, TRUE);
if (class_name == NULL)
_gtk_css_parser_error (parser, "Expected valid win32 theme name");
return NULL;
}
- canonical_class_name = canonicalize_class_name (class_name);
- theme = gtk_win32_theme_lookup (canonical_class_name);
- g_free (canonical_class_name);
+ theme = gtk_win32_theme_lookup (class_name);
g_free (class_name);
return theme;
#endif
}
-gboolean
-_gtk_win32_theme_color_resolve (const char *theme_class,
- gint id,
- GdkRGBA *color)
+void
+gtk_win32_theme_get_color (GtkWin32Theme *theme,
+ gint id,
+ GdkRGBA *color)
{
#ifdef G_OS_WIN32
- GtkWin32Theme *theme;
HTHEME htheme;
DWORD dcolor;
- theme = gtk_win32_theme_lookup (theme_class);
- if (use_xp_theme && get_theme_sys_color != NULL)
+ if (use_xp_theme && GetThemeSysColor != NULL)
{
htheme = gtk_win32_theme_get_htheme (theme);
- /* if htheme is NULL, it will just return the GetSystemColor()
- value */
- dcolor = get_theme_sys_color (htheme, id);
+ /* if htheme is NULL, it will just return the GetSysColor() value */
+ dcolor = GetThemeSysColor (htheme, id);
}
else
dcolor = GetSysColor (id);
- gtk_win32_theme_unref (theme);
-
color->alpha = 1.0;
color->red = GetRValue (dcolor) / 255.0;
color->green = GetGValue (dcolor) / 255.0;
#else
gdk_rgba_parse (color, "pink");
#endif
- return TRUE;
}
void
#define GTK_WIN32_THEME_SYMBOLIC_COLOR_NAME "-gtk-win32-color"
+GtkWin32Theme * gtk_win32_theme_lookup (const char *class_name);
GtkWin32Theme * gtk_win32_theme_parse (GtkCssParser *parser);
GtkWin32Theme * gtk_win32_theme_ref (GtkWin32Theme *theme);
int height,
int *x_offs_out,
int *y_offs_out);
-int gtk_win32_theme_get_size (GtkWin32Theme *theme,
- int id);
-
-gboolean _gtk_win32_theme_color_resolve (const char *theme_class,
- gint id,
- GdkRGBA *color);
+int gtk_win32_theme_get_size (GtkWin32Theme *theme,
+ int id);
+void gtk_win32_theme_get_color (GtkWin32Theme *theme,
+ gint id,
+ GdkRGBA *color);
G_END_DECLS